<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="kygcxx">
    <meta name="author" content="xxf">
    <title>信息平台</title>
    <link href="sb2/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="sb2/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<style type="text/css">
html,body {
	height: 100%;
	background-color:rgb(102,153,255);
}
.box {
	margin: 0 auto;
	position: relative;
	max-width:500px;
	height: 100%;
}
.login-box {
	margin: 0 auto;	
	width: 100%;
	height: 400px;
	position: absolute;
	top: 50%;

	margin-top: -200px;
	/*设置负值，为要定位子盒子的一半高度*/
	
}
@media screen and (min-width:500px){
	.login-box {
		left: 50%;
		/*设置负值，为要定位子盒子的一半宽度*/
		margin-left: -250px;
	}
}	

.form {
	width: 100%;
	max-width:500px;
	height: 275px;
	margin: 25px auto 0px auto;
	padding-top: 25px;
}	
.login-content {
	height: 300px;
	width: 100%;
	max-width:500px;
	background-color: rgb(194,211,255);
	float: left;
}		
	
	
.input-group {
	margin: 0px 0px 30px 0px !important;
}
.form-control,
.input-group {
	height: 40px;
}

.form-group {
	margin-bottom: 0px !important;
}
.login-title {
	padding: 20px 10px;
	background-color: rgb(41,61,102);
}
.login-title h1 {
	margin-top: 10px !important;
}
.login-title small {
	color: #fff;
}

.link p {
	line-height: 20px;
	margin-top: 30px;
}
.btn-sm {
	padding: 8px 24px !important;
	font-size: 16px !important;
}
</style>

</head>

<body>
<div class="box">
		<div class="login-box">
			<div class="login-title text-center">
				<h1><small>登录</small></h1>
			</div>
			<div class="login-content ">
			<div class="form">
				<div class="form-group">
					<div class="col-xs-12  ">
						<div class="input-group">
							<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
							<input type="text" id="username" name="username" class="form-control" placeholder="用户名" required >
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-xs-12  ">
						<div class="input-group">
							<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
							<input type="password" id="password" name="password" class="form-control" placeholder="密码" required >
						</div>
					<input type="checkbox" id="rmbUser" name="rmbUser" checked>记住用户名
					</div>
				</div>
				<div class="form-group form-actions">
					<div class="col-xs-4 col-xs-offset-4 ">
						<button id="login" class="btn btn-sm btn-info" onclick="login()"><span class="glyphicon glyphicon-off"></span> 登录</button>
					</div>
				</div>
				<div class="form-group">
					<!-- <div class="col-xs-6 link">
						<p class="text-center remove-margin"><small>忘记密码？</small> <a href="javascript:alert('暂不支持，有疑问请联系管理员！');" ><small>找回</small></a>
						</p>
					</div>
					-->
				</div>
			</div>
		</div>
	</div>
</div>
	<script src=js/jquery.js></script>
    <script src=js/bootstrap.min.js></script>
    <script src=js/jquery.xxfset.js></script>
    <script src=js/jquery.cookie.js></script>
    <script type="text/javascript">
	$(function(){
		if ($.cookie("rmbUser") == "true") {
	        $("#rmbUser").attr("checked", true);
	        $("#username").val($.cookie("userName"));
	        $("#password").val($.cookie("passWord"));
	    }
	});
	function login(){
        var un = $("#username").val();
        var pw = $("#password").val();
        if(un.length<1||pw.length<1){
			$.xalert("输入错误!");
			return;
        }
        $.xloading(1);
        $.post("login",{username:un,password:pw},function(data){
        	if(data==1){
        		saveUserInfo();
				location.href='admin';
			}else if(data==0){
				$.xloading(0);
				$.xalert("用户名或密码错！");
			}else{$.xloading(0);alert(data);}
        });
	}
	function saveUserInfo() {
	    if ($("#rmbUser").is(":checked")) {
	        var userName = $("#username").val();
	        var passWord = $("#password").val();
	        $.cookie("rmbUser", "true", { expires: 27 }); // 存储一个带7天期限的 cookie
	        $.cookie("userName", userName, { expires: 27 }); // 存储一个带7天期限的 cookie
	        $.cookie("passWord", passWord, { expires: 27 }); // 存储一个带7天期限的 cookie
	    }
	    else {
	        $.cookie("rmbUser", "false", { expires: -1 });        // 删除 cookie
	        $.cookie("userName", '', { expires: -1 });
	        $.cookie("passWord", '', { expires: -1 });
	    }
	}
    </script>
</body>

</html>